home *** CD-ROM | disk | FTP | other *** search
- Path: news1.h1.usa.pipeline.com!usenet
- From: grantp@usa.pipeline.com
- Newsgroups: comp.lang.c++
- Subject: Re: Filesize
- Date: 29 Jan 1996 11:57:14 GMT
- Organization: Kalevi, Inc.
- Message-ID: <4eicmq$r69@news1.usa.pipeline.com>
- NNTP-Posting-Host: pipe11.h1.usa.pipeline.com
- X-PipeUser: grantp
- X-PipeHub: usa.pipeline.com
- X-PipeGCOS: (Pete)
- X-Newsreader: Pipeline USA v3.3.0
-
- On Jan 29, 1996 11:31:25 in article <Filesize>, 'Daniel Ponti
- <daniel.ponti@ubs.ch>' wrote:
-
-
- >How can i get the size of a file in c?
- >There exists one with a structure stat and a function stat, but
- >this does not work under c++ (the function should also work in c++).
-
- I've found the following to work correctly under all platforms
- with which I work:
-
- 1. Open the file in binary mode using stdio fopen();
- 2. Use fseek(FilePointer, 0L, SEEK_END); to position file at end.
- 3. Call ftell() to get the file length.
- 4. Either close the file or reset back to start with fseek()
-
- Note binary mode. In text mode you get the wrong answer in DOS.
-
- If SEEK_END isn't defined on your machine, #define it as 2
-
- --
- Pete Grant
- Kalevi, Inc.
- Object Oriented Software Development
-